Compile 2013 VS Community Workflow

Aim

To show one workflow for setting up a Windows pc for compiling OpenCPN.

The pc used was a 'win-32-x86 machine', running Windows 8.1.

If you are running 'x64' you will need to download the 64 bit installers for some of the programs used here. This applies to:

The steps will follow the instructions here.

'Navigate' means using 'Windows Explorer' to find a folder or file.

'cd' or 'CD' is used in a Terminal window to 'change directory' (aka 'change folder')

Method

Install Visual Studio Community 2013

https://www.visualstudio.com/en-us/news/releasenotes/vs2013-community-vs

Install Git

Get the Git installation packages from https://git-for-windows.github.io/

Install CMake

Install Poedit

Get the latest 'Poedit' installation package from http://www.poedit.net

  1. Install 'Poedit'.
  2. Add 'C:\Program Files\Poedit\GettextTools\bin' to the PATH environment variable.

Note: If you look in the 'C:\Program Files\Poedit\GettextTools\bin' folder you will see the file 'msgfmt.exe' which does the work of the program.

Install NSIS

In case you want to create installation packages, install NSIS Unicode 2.46.5 from http://www.scratchpaper.com/

There is a “bug” in CMake, which only looks at “HKEY_LOCAL_MACHINE\SOFTWARE\NSIS” for the installation location of NSIS

The Unicode version adds its registry key in “HKEY_LOCAL_MACHINE\SOFTWARE\NSIS\Unicode”.

Some registry tweaking is needed.

Note: If you are running a 64-bit machine (x64) the key is located in 'HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432node\NSIS\Unicode'

Note: If you are running a 64-bit machine (x64) the location is 'HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432node\NSIS'.

To make the installer package use proper language name translations, it is necessary to modify file 'C:\Program Files\NSIS\Unicode\Contrib\Language files\Norwegian.nsh' and change the line

!insertmacro LANGFILE "Norwegian" "Norwegian"

to

!insertmacro LANGFILE "Norwegian" "Norsk"

The 'C:\Program Files\NSIS\Unicode\Contrib\Language files\Norwegian.nsh' is edited.

Due to 'Security' you will need to add 'Write' permission to this file. Without this you will not be able to save the changes.

Compiling wxWidgets 3.0.2

Start the 'VS2013 x86 Native Tools Command Prompt'

Note: This can be confusing!!! Even though we have installed 'Visual Studio Community 2013' when you search the 'Program Files' folder you will see 'Microsoft Visual Studio 12' but not 'Microsoft Visual Studio 13'. When you look at the installed 'Apps' you will see this:

This will open a folder of shortcuts.

You are in the folder 'C:\Program Files\Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts'

Note: On a 64 bit machine the prompt is 'VS2013 x64 Command Prompt'

Title is 'VS2013', the text reads 'Visual Studio 12'. You get the picture!!!

An easy way to enter the correct folder (cd) for 'wxWidgets 3.0.2\build\msw' is to navigate to that folder with 'Explorer'.

Build both release and debug configurations, which will be compatible with Windows XP.

RELEASE VERSION
nmake -f makefile.vc BUILD=release SHARED=1 CFLAGS=/D_USING_V120_SDK71_ CXXFLAGS=/D_USING_V120_SDK71_

DEBUG VERSION
nmake -f makefile.vc BUILD=debug SHARED=1 CFLAGS=/D_USING_V120_SDK71_ CXXFLAGS=/D_USING_V120_SDK71_

You will find that a number of files have been made in the folder 'c:\wxWidgets-3.0.2\lib\vc-dll'.

Some of the filenames start 'wxmsw30u' and others 'wxmsw30ud' corresponding to the 'Release' and 'Debug' versions.

This completes the preparations for building the OpenCPN program.

Building OpenCPN

Get the OpenCPN source

git clone git://github.com/OpenCPN/OpenCPN.git


Note: If you want the source code for the latest stable release (4.4.0 at time of writing) you need to locate that source on GitHub.com:

https://github.com/OpenCPN/OpenCPN/tree/v4.4.0


Get the binary dependency files

Sorry, this needs another program - 7Zip.

'7z' files can now be opened and extracted with this program.

Make a Visual Studio solution for building OpenCPN

[The command prompt shortcut is in the folder 'C:\Program Files\Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts']

mkdir build
cd build
cmake -T v120_xp ..

* Close the Terminal window.
* This has created the Visual Studio solution file 'OpenCPN.sln'.

Build OpenCPN



Make a package to install OpenCPN

This assumes that you have installed 'NSIS' (The guide was here).

Install OpenCPN

OpenCPN (Version 4.4.0) and the four plugins included in the source files have been built successfully.